/** @odoo-module **/

import {registry} from "@web/core/registry";

window.zspeech = new SpeechSynthesisUtterance();

const doMessageNotice = function (env, action) {
    let params = action.params;
    env.services.action.doAction({
        type: "ir.actions.client",
        tag: "display_notification",
        params: {
            sticky: params.notice_sticky || false,  type: params.notice_type || "warning",
            title: params.notice_title || "通知信息",  message: params.notice_message || ""
        }
    });
    if(!!params.notice_speech && !!params.notice_message){
        zspeech.text = params.notice_message;
        zspeech.lang = "zh-CN";
        zspeech.volume = "1";
        zspeech.rate = 1;
        zspeech.pitch = 1;
        speechSynthesis.speak(zspeech);
    }
}

registry.category('actions').add('justdoo.message.notice', doMessageNotice);